package com.cq.school.factory;

import com.cq.school.service.ArticleService;
import com.cq.school.service.SchoolService;
import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

/**
 * Created with IntelliJ IDEA.
 * User: huke
 * Date: 14-3-27
 * Time: 下午11:39
 * To change this template use File | Settings | File Templates.
 */
public class ServiceFactory implements ApplicationContextAware {
    private static  ApplicationContext ctx;

    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        ctx = applicationContext;
    }

    public static SchoolService getSchoolService(){
        return (SchoolService)ctx.getBean("schoolService");
    }

    public static ArticleService getArticleService(){
        return (ArticleService)ctx.getBean("articleService");
    }
}
